package dbapi

import (
	"GO_BACK/model/data"
	"fmt"
	"gorm.io/gorm"
)

func QuerybyidPwd(id int64, password string) *data.PostgresUserInfo {
	var db *gorm.DB
	var err error
	db, err = PgDbConnect()
	if err != nil {
		return nil
	}
	result := &data.PostgresUserInfo{}
	db.Where("id=? and password=?", id, password).First(&result)
	return result
}
func Querybyemail(email string) *data.PostgresUserInfo {
	var db *gorm.DB
	var err error
	db, err = PgDbConnect()
	if err != nil {
		return nil
	}
	result := &data.PostgresUserInfo{}
	db.Where("email=?", email).First(&result)
	return result
}
func QueryByVertifyCode(code string) bool {
	var db *gorm.DB
	var err error
	db, err = PgDbConnect()
	if err != nil {
		return false
	}
	var result *data.VerifyStruct
	db.Where("vertifycode=?", code).First(&result)
	fmt.Println("2,result.Email:" + result.Email + ",,," + "result.Vertifycode:" + result.Vertifycode)
	if result.Vertifycode == code {
		return true
	}
	return false
}
